package org.ranshiyan.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class KafkaProducer {

    @Autowired
    private KafkaTemplate kafkaTemplate;

    // 发送消息
    @GetMapping("/kafka")
    public String sendMessage1() {
        kafkaTemplate.send("topic1", "qwe");
        return "添加消息为:wqe";
    }
}
